package com.logic.saas.action.subscription;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;

import com.logic.saas.action.BaseAction;
import com.logic.saas.pojo.Qcode;
import com.logic.saas.pojo.SaasModule;
import com.logic.saas.pojo.SubscriptionInfo;
import com.logic.saas.service.applicationmodules.AppModuleService;
import com.logic.saas.service.subscription.SubscriptionService;
import com.logic.saas.util.AddLog;

public class SubscripInfoAction extends BaseAction{

	private static final long serialVersionUID = -2933614434535195667L;
	private String[] modules;
	private SubscriptionInfo subscriptionInfo;
	@Autowired
	private SubscriptionService subscriptionService;
	@Autowired
	private AppModuleService appModuleService;

	@Action(value="subscripInfo")
	@Override
	public String execute() {
		AddLog.addToLog(this.getClass(), AddLog.INFO, "forward to subcription information page.....");
		String returnedStr = SUCCESS;
		try {
			//查询subscription Period
			List<Qcode> subPeriod =subscriptionService.getSubPeriod();
			request.setAttribute("subPeriod", subPeriod);
			
			List<SaasModule> moduleList = appModuleService.findModulesByIds(modules);
			session.put("moduleList", moduleList);
			
		} catch (Exception e) {
			e.printStackTrace();
			this.addActionError(e.getMessage());
			returnedStr = ERROR;
		} 
        return returnedStr;
	}
	
	
	public String[] getModules() {
		return modules;
	}

	public void setModules(String[] modules) {
		this.modules = modules;
	}

	public SubscriptionInfo getSubscriptionInfo() {
		return subscriptionInfo;
	}

	public void setSubscriptionInfo(SubscriptionInfo subscriptionInfo) {
		this.subscriptionInfo = subscriptionInfo;
	}
}
